(function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("d3")):typeof define=="function"&&define.amd?define(["exports","vue","d3"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s.InteractiveRegionsMap={},s.Vue,s.d3))})(this,function(s,e,I){"use strict";function R(o){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const i in o)if(i!=="default"){const c=Object.getOwnPropertyDescriptor(o,i);Object.defineProperty(t,i,c.get?c:{enumerable:!0,get:()=>o[i]})}}return t.default=o,Object.freeze(t)}const l=R(I),B={class:"map-region"},E=["d"],_={__name:"MapRegion",props:["d","data","onclick"],setup(o){const t=o;return(i,c)=>(e.openBlock(),e.createElementBlock("g",B,[e.createElementVNode("path",{class:"map-region-path",d:t.d,onClick:c[0]||(c[0]=a=>o.onclick(a,o.data))},null,8,E)]))}},M={__name:"RegionInfo",props:["regionData"],emits:["next","previous"],setup(o){return(t,i)=>{const c=e.resolveComponent("v-card-title"),a=e.resolveComponent("v-card-text"),m=e.resolveComponent("v-spacer"),u=e.resolveComponent("v-btn"),p=e.resolveComponent("v-card-actions"),f=e.resolveComponent("v-card");return e.openBlock(),e.createBlock(f,{elevation:"3",id:"region-info-card"},{default:e.withCtx(()=>[e.createVNode(c,{class:"region-title"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.regionData.properties.NAME_1),1)]),_:1}),e.createVNode(a,{class:"region-info"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.regionData.properties),1)]),_:1}),e.createVNode(p,null,{default:e.withCtx(()=>[e.createVNode(m),e.createVNode(u,{variant:"text",onClick:i[0]||(i[0]=g=>t.$emit("next"))},{default:e.withCtx(()=>[e.createTextVNode(" previous ")]),_:1}),e.createVNode(u,{variant:"text",onClick:i[1]||(i[1]=g=>t.$emit("previous"))},{default:e.withCtx(()=>[e.createTextVNode(" next ")]),_:1})]),_:1})]),_:1})}}},b={class:"map-container w-100"},T=["width","height","transform","viewBox"],V={id:"regions-container"},j=e.createElementVNode("path",{fill:"none",stroke:"white","stroke-linejoin":"round"},null,-1),x=1500,D={__name:"RegionsMap",props:{width:{type:Number,default:900},height:{type:Number,default:900},regions:{type:Object,required:!0},regionsIndexes:{type:Object,default:{}}},setup(o){const t=o,i=t.regions.features.length,c=l.geoTransverseMercator().fitSize([t.width,t.height],t.regions),a=e.ref(0),m=e.ref(l.geoPath().projection(c)),u=e.ref(null),p=e.ref(null),f=e.ref(null),g=e.ref(null),k=e.ref(null),w=e.computed(()=>t.regions.features[a.value]);function z(n){n>=0&&n<i&&(a.value=n)}function P(n){for(let r=0;r<i;r++)if(t.regions[r].properties.id===n.properties.id)return r}function $(n){let r=n.properties.id;return t.regionsIndexes[r].index}function O(){a.value+=1,a.value===i&&(a.value=0),y()}function S(){a.value-=1,a.value<0&&(a.value=i-1),y()}function y(){let n=w.value.properties.id;document.getElementById(n).lastChild.dispatchEvent(new MouseEvent("click",void 0))}function q(n){const{transform:r}=n;g.value.attr("transform",r),g.value.attr("stroke-width",1/r.k)}function A(){f.value.transition().duration(x).call(p.value.transform,l.zoomIdentity,l.zoomTransform(f.value.node()).invert([t.width/2,t.height/2]))}function F(n,r){const[[d,N],[C,v]]=m.value.bounds(r);n.stopPropagation(),k.value.transition().style("fill",null),l.select(n.currentTarget).transition().style("fill","red");let h;t.regionsIndexes?h=$(r):h=P(r),z(h),f.value.transition().duration(x).call(p.value.transform,l.zoomIdentity.translate(t.width/2,t.height/2).scale(Math.min(8,.9/Math.max((C-d)/t.width,(v-N)/t.height))).translate(-(d+C)/2,-(N+v)/2))}return e.onMounted(()=>{p.value=l.zoom().scaleExtent([1,8]).on("zoom",q),f.value=l.select("svg").on("click",A).call(p.value),k.value=l.selectAll("path"),g.value=l.select("#regions-container")}),(n,r)=>(e.openBlock(),e.createElementBlock("div",b,[(e.openBlock(),e.createElementBlock("svg",{id:"map",width:t.width,height:t.height,transform:u.value,viewBox:[0,0,t.width,t.height]},[e.createElementVNode("g",V,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.regions.features,d=>(e.openBlock(),e.createBlock(_,{key:d.properties.NAME_1,id:d.properties.id,ref_for:!0,ref:"regionsRef",data:d,d:m.value(d),onclick:F},null,8,["id","data","d"]))),128)),j])],8,T)),e.renderSlot(n.$slots,"default",{regionData:w.value,onNext:O,onPrevious:S})]))}};s.MapRegion=_,s.RegionInfoCard=M,s.RegionsMap=D,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
